/**
 * @name goods
 * @desc 连接mysql数据库的goods，简单查询数据库数据
 */

const koaRouter = require("koa-router")
const { query } = require("../utils/db")

const router = koaRouter()

router.get("/get-goods", async ctx => {
    const cols = "id ,name, price"
    const sql = `SELECT ${cols} from goods;`

    const res = await query(sql)

    ctx.body = res.success ? { code: 1000, msg: "success", data: res.data } : { code: 1001, msg: "数据库查询错误" }
})

module.exports = router
